# Using a fitted lm model

library(interactions)
limited$treatment<-as.factor(limited$treatment)

limited<-limited%>%
  mutate(Treatment= recode_factor(.x=treatment, 
                                  `1`="Control",
                                  `2`="Boy",
                                  `3`="Girl"))
girlsexism<-lm(Author~Treatment*hostile_sexism+Treatment*ben_sexism+
                 Treatment*ben_men+Treatment*hostil_men, data=limited)
summary(girlsexism)

interact_plot(model = girlsexism, pred = hostile_sexism, modx = Treatment)


# Using interval feature

HS<-interact_plot(girlsexism, pred = hostile_sexism, modx = Treatment, interval = TRUE,
                  int.type = "confidence", int.width = .8)+
  xlab("Hostile sexism")+ylab("Authoritarianism")
HS


BS<-interact_plot(girlsexism, pred = ben_sexism, modx = Treatment, interval = TRUE,
                  int.type = "confidence", int.width = .8)+
  xlab("Benevolent sexism")+ylab("Authoritarianism")
BS

BM<-interact_plot(girlsexism, pred = ben_men, modx = Treatment, interval = TRUE,
                  int.type = "confidence", int.width = .8)+
  xlab("Benevolence toward men")+ylab("Authoritarianism")
BM

HM<-interact_plot(girlsexism, pred = hostil_men, modx = Treatment, interval = TRUE,
                  int.type = "confidence", int.width = .8)+
  xlab("Hostility toward men")+ylab("Authoritarianism")
HM


library(cowplot)
pdf(file="Figure8.pdf")

plot_grid(HS, BS, BM, HM)
dev.off()

